package com.firebugsoft.metadata.api.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.firebugsoft.common.mvc.json.Body;
import com.firebugsoft.metadata.dubbo.api.IRegionService;
import com.firebugsoft.metadata.dubbo.api.to.RegionTO;

@RestController
@RequestMapping(value = { "/region" })
public class RegionController {
    @Resource
    private IRegionService regionService;

    @RequestMapping(value = { "/find" })
    public Body find(String code) {
        RegionTO to = regionService.findByCode(code);
        return Body.newInstance(to);
    }

    @RequestMapping(value = { "/list" })    
    public Body list(String pcode) {
        List<RegionTO> tos = regionService.findByPcode(pcode);
        return Body.newInstance(tos);
    }
}
